//
//  CGQDeviceWaringTableViewCell.swift
//  SheYangBigData
//
//  Created by 叁拾叁 on 2021/5/11.
//  Copyright © 2021 叁拾叁. All rights reserved.
//


import UIKit


class CGQDeviceWaringTableViewCell: SYBaseCell {
    
    
    let title: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 17.autoBoldFontSize()
        v.text = "设备离线"
        return v
    }()
    
    let subTitle: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x666666)
        v.font = 14.autoFontSize()
        v.numberOfLines = 0
        v.text = "蝴蝶兰-北展厅温湿度设备已离线，请立即...北展厅温湿度设备已离线，请立即...北展厅温湿度设备已离线，请立即...北展厅温湿度设备已离线，请立即...北展厅温湿度设备已离线，请立即..."
        return v
    }()
    
    let time: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x999999)
        v.font = 12.autoFontSize()
        v.text = "3月10日"
        return v
    }()
    
    let pic: UIImageView = {
        let v: UIImageView = UIImageView()
        v.sy_name("shebei_yujing_icon")
        return v
    }()
    
    let arrow: UIImageView = {
        let v: UIImageView = UIImageView()
        v.sy_name("arrow_gray")
        v.isHidden = true
        
        return v
    }()
    
    
    var tixianBt: UIButton = {
        let v = UIButton()
        v.setTitle("预警处理 >", for: .normal)
        v.setTitleColor(.white, for: .normal)
        v.titleLabel?.font = 12.autoFontSize()
        v.layer.cornerRadius = 11
        //        v.layer.borderWidth = 1
        //        v.layer.borderColor = UIColor(hex: 0x00C793).cgColor
        v.backgroundColor = UIColor(hex: 0x0782FF)
        return v
    }()
    
    
    
    
    public func configureMessageView(model:NSMessageRecordsModel){
        
        
        title.text = model.warningName ?? "暂无"
        subTitle.text = model.remarks ?? "暂无内容"
        time.text = model.createDate ?? "无"
        
        if model.isDeal == 1 {
            
            self.tixianBt.backgroundColor = UIColor(hex: 0xb2b2b2)
            self.tixianBt.setTitle("已处理", for: .normal)
            self.tixianBt.isUserInteractionEnabled = false
            
        }else{
            self.tixianBt.isUserInteractionEnabled = true
        }
        
        
    }
    override func initViews() {
        
        self.backgroundColor = .white
        contentView.addSubview(pic)
        contentView.addSubview(title)
        contentView.addSubview(subTitle)
        contentView.addSubview(arrow)
        contentView.addSubview(time)
        contentView.addSubview(lineView)
        contentView.addSubview(tixianBt)
        
        
        pic.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(autoWidth(10))
            make.width.equalTo(33.autoWidth())
            make.height.equalTo(33.0.autoWidth())
            make.top.equalToSuperview().offset(autoWidth(21))
            //            make.centerY.equalToSuperview()
        }
        title.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(20.autoWidth())
            make.left.equalToSuperview().offset(autoWidth(53))
            make.right.equalToSuperview().offset(autoWidth(-12.0))
            make.height.equalTo(17.autoWidth())
        }
        subTitle.snp.makeConstraints { (make) in
            make.top.equalTo(title.snp.bottom).offset(autoWidth(14))
            make.right.equalToSuperview().offset(autoWidth(-40))
            make.left.equalToSuperview().offset(autoWidth(53))
            
        }
        arrow.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.right.equalToSuperview().offset(autoWidth(-10.0))
            make.width.equalTo(8.autoWidth())
            make.height.equalTo(14.autoWidth())
        }
        time.snp.makeConstraints { (make) in
            make.centerY.equalTo(title)
            make.right.equalToSuperview().offset(autoWidth(-13.0))
            make.height.equalTo(10.autoWidth())
        }
        
        tixianBt.snp.makeConstraints { (make) in
            make.top.equalTo(subTitle.snp.bottom).offset(autoWidth(10))
            make.right.equalToSuperview().offset(autoWidth(-10))
            make.bottom.equalToSuperview().offset(autoWidth(-5))
            make.width.equalTo(autoWidth(70))
            make.height.equalTo(autoWidth(22))
        }
        
        lineView.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(autoWidth(53))
            make.right.equalToSuperview().offset(autoWidth(-10.0))
            make.height.equalTo(0.5.autoWidth())
            make.bottom.equalToSuperview()
        }
    }
}


